<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>position定位</title>
    <style>
        *{
            padding:0px;
            margin:0px;
            box-sizing: border-box;
        }

        div{
            width: 200px;
            height: 200px;
            overflow: hidden; 
        }

        #d1{
            background-color: red;
            position: absolute; 
            z-index:15;
        }
        #d2{
            background-color: blue;
            /* 定位方式设置为相对定位 */
            position: relative;
            top:20px;
            left:20px;
            z-index:10;

        }
        #d3{
            background-color: green;
            /* absolute表示绝对定位，根据第一个定位方式为relative/absolute的父元素进行定位，否则根据body进行定位 */
            position: absolute;
            top:40px;
            left:40px;
            z-index:1;
        }
    </style>
</head>
<body>
    <div id="d1"></div>
    <div id="d2"></div>
    <div id="d3"></div>
    
</body>
</html>